      INTEGER          FUNCTION ISAMAX( N, SX, INCX )
*
*     finds the index of element having max. absolute value.
*     jack dongarra, linpack, 3/11/78.
*
*     .. Scalar Arguments ..
      INTEGER                           INCX, N
*     ..
*     .. Array Arguments ..
      REAL                              SX( 1 )
*     ..
*     .. Local Scalars ..
      INTEGER                           I, IX
      REAL                              SMAX
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC                         ABS
*     ..
*     .. Executable Statements ..
*
      ISAMAX = 0
      IF( N.LT.1 )
     $   RETURN
      ISAMAX = 1
      IF( N.EQ.1 )
     $   RETURN
      IF( INCX.EQ.1 )
     $   GO TO 30
*
*        code for increment not equal to 1
*
      IX = 1
      IF( INCX.LT.0 )
     $   IX = 1 - ( N-1 )*INCX
      SMAX = ABS( SX( IX ) )
      IX = IX + INCX
      DO 20 I = 2, N
         IF( ABS( SX( IX ) ).LE.SMAX )
     $      GO TO 10
         ISAMAX = I
         SMAX = ABS( SX( IX ) )
   10    IX = IX + INCX
   20 CONTINUE
      IF( INCX.LT.0 )
     $   ISAMAX = N - ISAMAX + 1
      RETURN
*
*        code for increment equal to 1
*
   30 SMAX = ABS( SX( 1 ) )
      DO 40 I = 2, N
         IF( ABS( SX( I ) ).LE.SMAX )
     $      GO TO 40
         ISAMAX = I
         SMAX = ABS( SX( I ) )
   40 CONTINUE
      RETURN
      END
